document.addEventListener("DOMContentLoaded", () => {
    const titleInput = document.querySelector("input[name='title']");
    const contentInput = document.querySelector("textarea[name='content']");
    const previewArea = document.querySelector("#preview");

    if (titleInput && contentInput && previewArea) {
        const updatePreview = () => {
            const title = titleInput.value.trim() || "Title preview...";
            const content = contentInput.value.trim() || "Content preview...";
            previewArea.innerHTML = `<h2>${title}</h2><p>${content}</p>`;
        };

        titleInput.addEventListener("input", updatePreview);
        contentInput.addEventListener("input", updatePreview);
    }
});
